__version__ = '0.1.0'

import os.path
import click
from PIL import Image

def clip(infile, width):
    outfile, ext = os.path.splitext(infile)
    with Image.open(infile) as im:
        ratio = width / im.width
        nw, nh = int(im.width*ratio), int(im.height*ratio)
        nim = im.resize((nw, nh))
        nim.save(outfile + f"-{nw}x{nh}" + ext)


@click.command()
@click.argument('src', nargs=-1)
def cmd(src):
    for fp in src:
        clip(fp, 356)
